export default {
    install(Vue) {
        // 传递this,即binding.value等于使用指令组件的this,拿到this的scopeId并赋值给想要的对象
        Vue.directive('scoped', function (el, binding) {
            if (!binding.value) return
            const scopedId = binding.value.$options._scopeId
            if (!scopedId) return
            const componentTag = el.__vue__.$vnode.tag
            const target = []

            if (componentTag.includes('ElPopover')) {
                // ElPopover的弹出层是el的第0个children
                target.push(el.children[0])
            } else if (componentTag.includes('LTooltip')) {
                // 这里加别的判断
                console.log(el);
            } else {
                target.push(el)
            }
            target.forEach(el => el.setAttribute(scopedId, ''))
        })
    }
}
